Imports System.Data.OleDb
Imports BUS
Imports DTO
Public Class frmThongKeDoanhThuTheoNgay
    Private hdBus As New HoaDonBUS()
    Private Sub frmThongKeDoanhThuTheoNgay_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
    Protected Function ConnectionData() As OleDbConnection
        Dim strCn As String
        strCn = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = QLKS.mdb"
        Dim cn As New OleDbConnection(strCn)
        cn.Open()
        Return cn
    End Function
    Private Sub LoadDuLieu()
        Dim cn As OleDbConnection
        cn = Me.ConnectionData()
        Dim strSQL As String
        Dim tungay As Date = txtTungay.Text
        Dim denngay As Date = txtDenngay.Text
        strSQL = "SELECT HoaDon.MaHoaDon, HoaDon.TenHoaDon, HoaDon.MaPhieuThue, HoaDon.NgayLapHoaDon, HoaDon.TongTien    FROM(HoaDon)WHERE (((HoaDon.NgayLapHoaDon) Between #" + tungay + "# And #" + denngay + "#));"
        Dim da As OleDbDataAdapter
        da = New OleDbDataAdapter(strSQL, cn)
        Dim cmb As New OleDbCommandBuilder(da)

        Dim DataSet1 As New DataSet()
        da.Fill(DataSet1, "TestDB")
        dataThongke.DataSource = DataSet1.Tables("TestDB")

    End Sub

    Private Sub btnThongKe_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThongKe.Click
        LoadDuLieu()
    End Sub

    Private Sub btnIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIn.Click
        Dim tungay As Date = txtTungay.Text
        Dim denngay As Date = txtDenngay.Text
        Dim frmTkdttheoNgay As New frmThongKeTheoDoanhThu()
        frmTkdttheoNgay.Show()
        frmTkdttheoNgay.inThongKe(tungay, denngay)
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub
End Class